package com.foreverwin.jzymes.report.fqc.controller;

import com.foreverwin.jzymes.common.util.CommonMethods;
import com.foreverwin.jzymes.framework.annotation.ParamBind;
import com.foreverwin.jzymes.framework.base.AjaxResult;
import com.foreverwin.jzymes.framework.exception.BusinessException;
import com.foreverwin.jzymes.production.fqc.domain.FqcCheck;
import com.foreverwin.jzymes.production.fqc.domain.FqcCheckBox;
import com.foreverwin.jzymes.production.fqc.domain.FqcCheckNc;
import com.foreverwin.jzymes.production.fqc.service.IFqcAdviceService;
import com.foreverwin.jzymes.report.fqc.service.IFqcCheckReportService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/report/fqc")
public class FqcReportController {
    @Autowired
    IFqcCheckReportService fqcCheckReportService;

    /**
     * fqc报表
     *
     * */
    @RequestMapping("/fqcCheckReport")
    public AjaxResult fqcCheckReport(@RequestParam Map<String , Object> jsonMap){
        try{
            jsonMap.put("site",CommonMethods.getSite());
            List<FqcCheck> list =  fqcCheckReportService.findFqcCheckByReport( jsonMap );
            return AjaxResult.returnSuccess().put("value",list);
        }catch ( BusinessException e ){
            return AjaxResult.returnError( e.getMessage() );
        }
    }

    /**
     * fqcBox
     *
     * */
    @RequestMapping("/fqcCheckBox")
    public AjaxResult fqcCheckBox(@RequestParam Map<String , Object> jsonMap){
        try{

            List< Map<String , Object> > list =  fqcCheckReportService.findFqcCheckBoxByReport( jsonMap );
            return AjaxResult.returnSuccess().put("value",list);
        }catch ( BusinessException e ){
            return AjaxResult.returnError( e.getMessage() );
        }
    }

    /**
     * fqcNC
     *
     * */
    @RequestMapping("/fqcCheckNC")
    public AjaxResult fqcCheckNC(@RequestParam Map<String , Object> jsonMap){
        try{

            List< Map<String , Object> > list =  fqcCheckReportService.findFqcCheckNCByReport( jsonMap );
            return AjaxResult.returnSuccess().put("value",list);
        }catch ( BusinessException e ){
            return AjaxResult.returnError( e.getMessage() );
        }
    }
}
